import VueI18n from 'vue-i18n'
import EN from './en';
import ZH from './zh';
import Vue from 'vue'

Vue.use(VueI18n)
const messages = {
    en: {
        ...EN
    },
    zh: {
        ...ZH
    }
}
const getCurrentLanguage = () => {
    const UALang = navigator.language //zh-CN
    const langCode = UALang.indexOf('zh') !== -1 ? 'zh' : 'en'
    localStorage.setItem('lang', langCode)
    return langCode
}
const i18n = new VueI18n({
    legacy: false,
    globalInjection: true,
    locale: getCurrentLanguage() || 'zh',
    messages: messages
})

export default i18n

